package com.redwine.app;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.lidroid.xutils.view.annotation.event.OnClick;
import com.redwine.app.net.NetworkConstants;
import com.redwine.app.utils.Utils;
import com.redwine.app.view.shareDialog.BottomDialog;

/**
 * 关于高迪
 * 作者：gassion on 17/9/9 13:25
 * 最可怕的敌人，就是没有坚强的信念。
 */
public class AboutAppActivity extends BaseActivity {

    @ViewInject(R.id.header_title)
    private TextView headerTitle;
    @ViewInject(R.id.layout_back)
    private LinearLayout layoutBack;
    private Intent intent;
    @ViewInject(R.id.about_app_tv_version_number)
    private TextView aboutAppTvVersionNumber;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_about_app);
        ViewUtils.inject(this);
        initView();
    }

    private void initView() {
        headerTitle.setText(getString(R.string.about_app_name));
        layoutBack.setVisibility(View.VISIBLE);
        aboutAppTvVersionNumber.setCompoundDrawables(null, null, getIdDrawable(R.mipmap.icon_more), null);
        aboutAppTvVersionNumber.setText(BuildConfig.VERSION_NAME);
    }

    @OnClick({R.id.layout_back, R.id.about_app_ll_version, R.id.about_app_ll_high_praise,
            R.id.about_app_ll_recommended, R.id.about_app_ll_user_agreement})
    public void mClick(View v) {
        switch (v.getId()) {

            case R.id.layout_back:
                finish();
                break;

            case R.id.about_app_ll_version:
                //查看新版本
                intent = new Intent(AboutAppActivity.this, AboutAppVersionActivity.class);
                startActivity(intent);
                break;

            case R.id.about_app_ll_high_praise:
                //好评
                Utils.showToast("给好评");
                break;

            case R.id.about_app_ll_recommended:
                //推荐
                new BottomDialog(AboutAppActivity.this)
                        .toShareParams("红酒app", "http://www.bejson.com/", "https://t-app.baisouhj.com/image/hongjiu/icon.jpg",
                                "推荐下载“酒工”手机客户端，酒类交易平台。").show();
                break;

            case R.id.about_app_ll_user_agreement:
                //用户协议
                intent = new Intent(AboutAppActivity.this, CommonWebViewActivity.class);
                intent.putExtra(CommonWebViewActivity.TITLE_PARAMS, getString(R.string.about_user_agreement));
                String url = NetworkConstants.WEB_INDEX_URL;
                intent.putExtra(CommonWebViewActivity.LOAD_URL, url);
                startActivity(intent);
                break;


        }
    }

    @Override
    public void onResume() {
        super.onResume();
        dismissWaiting();
    }
}
